package org.jactao.common;

import org.jactao.registry.LRegistry;

/**
 * Created by fanzetao on 2018/4/10.
 */
public class LReferConfig {
    private Object proxy;
    private Class interfaceClass;
    private LRegistry registry;
    public Class getInterfaceClass() {
        return interfaceClass;
    }
    private String version = LConstants.defaultVersion;
    private int timeout = LConstants.defaultTimeout;
    private boolean async = false;
    private String loadBalance = LConstants.defaultLoadBalance;

    public void setInterfaceClass(Class interfaceClass) {
        this.interfaceClass = interfaceClass;
    }

    public String getVersion() {
        return version;
    }

    public void setVersion(String version) {
        this.version = version;
    }

    public int getTimeout() {
        return timeout;
    }

    public void setTimeout(int timeout) {
        this.timeout = timeout;
    }

    public boolean isAsync() {
        return async;
    }

    public void setAsync(boolean async) {
        this.async = async;
    }

    public Object getProxy() {
        return proxy;
    }

    public void setProxy(Object proxy) {
        this.proxy = proxy;
    }

    public LRegistry getRegistry() {
        return registry;
    }

    public void setRegistry(LRegistry registry) {
        this.registry = registry;
    }

    public String getLoadBalance() {
        return loadBalance;
    }

    public void setLoadBalance(String loadBalance) {
        this.loadBalance = loadBalance;
    }

    public void checkRequired() {
        if(interfaceClass == null)
            throw new LException("interfaceClass not null");

        if(registry == null)
            throw new LException("registry required");
        else
        if(!registry.running())
            throw new LException("registry not running");
    }
}
